 /* 
 * File:   cText.cpp
 * Author: josep
 * 
 * Created on 4 / gener / 2011, 00:04
 */

#include "cPositionedMessage.h"

cPositionedMessage::cPositionedMessage() {
    message="";
}

cPositionedMessage::cPositionedMessage(const cPositionedMessage& orig):cPositionedObject(orig) {
    message=orig.message;
    font=orig.font;
    spacing=orig.spacing;
    for(int i=0; i<3; i++){
        color[i]=orig.color[i];
    }
}

cPositionedMessage::~cPositionedMessage() {
}
void cPositionedMessage::SetSpacing(int spacing) {
    this->spacing = spacing;
}
int cPositionedMessage::GetSpacing() const {
    return spacing;
}
void cPositionedMessage::SetFont(void* font) {
    this->font = font;
}
void* cPositionedMessage::GetFont() const {
    return font;
}
void cPositionedMessage::SetMessage(const char* message) {
    this->message = (char*) message;
}

char* cPositionedMessage::GetMessage() {
    return message;
}

void cPositionedMessage::Draw(){
    int x;
    char *c;
    GLfloat ccolor[4];
    
    x=GetPosX();
    
    glGetFloatv(GL_CURRENT_COLOR, ccolor);

    glColor3f(color[0], color[1], color[2]);
    for (c=message; *c != '\0'; c++) {

	glRasterPos2f(x,GetPosY());
	glutBitmapCharacter(font, *c);
	x = x + glutBitmapWidth(font,*c) + spacing;
    }
    
    glColor3f(ccolor[0], ccolor[1], ccolor[2]);
}

void cPositionedMessage::SetColor(float colorR, float colorG, float colorB){
    color[0]=colorR;
    color[1]=colorG;
    color[2]=colorB;
}
const float*  cPositionedMessage::GetColor(){
    return color;
}

